Total Complexity | 5 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from 'typeorm'; |
||
3 | |||
4 | @Entity() |
||
5 | export class Customer { |
||
6 | @PrimaryGeneratedColumn('uuid') |
||
7 | private id: string; |
||
8 | |||
9 | @Column({type: 'varchar', nullable: false}) |
||
10 | private name: string; |
||
11 | |||
12 | @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'}) |
||
13 | private createdAt: Date; |
||
14 | |||
15 | @ManyToOne(type => Address, {nullable: true, onDelete: 'SET NULL'}) |
||
16 | private address: Address; |
||
17 | |||
18 | constructor(name: string, address: Address) { |
||
19 | this.name = name; |
||
20 | this.address = address; |
||
21 | } |
||
22 | |||
23 | public getId(): string { |
||
24 | return this.id; |
||
25 | } |
||
26 | |||
27 | public getName(): string { |
||
28 | return this.name; |
||
29 | } |
||
30 | |||
31 | public getCreatedAt(): Date { |
||
32 | return this.createdAt; |
||
33 | } |
||
34 | |||
35 | public getAddress(): Address { |
||
36 | return this.address; |
||
37 | } |
||
38 | |||
39 | public updateName(name: string): void { |
||
40 | this.name = name; |
||
41 | } |
||
43 |